<template>
  <el-cascader :options="deptName" :show-all-levels="false" :props="props" v-model="id" filterable @change="toParent"/>

</template>

<script>
import {getAllDept,deptChildRecursion} from "@/api/dept";
export default {
  name: "DeptNameSelect",
  data() {
    return {
      id:'',
      deptName:'',
      props:{
        label:'deptName',
        value:'id',
        checkStrictly:true
      },
    }
  },
  props:['deptId'],
  mounted() {
    this.loadData()
  },
  methods:{
    toParent(value) {
      this.$emit("getId",value.slice(-1)[0])
    },
    async loadData() {
      const t =await getAllDept();
      const a = deptChildRecursion(t.data.data)
      this.deptName = a;
    }
  }
}
</script>

<style scoped>

</style>